package com.lipy.dubbodb.controller;

import com.lipy.dubbocommon.entity.Person;
import com.lipy.dubbodb.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.sql.DataSource;
import java.util.List;

/**
 * @description:
 * @author: lipy
 * @create: 2020-10-22 21:09
 **/
@RestController
@RequestMapping("/person")
public class PersonController {

    @Autowired
    PersonService personService;

    @Autowired
    ApplicationContext applicationContext;

    @GetMapping("/all")
    public Object getAll(){
        List<Person> all = personService.getAll();
        return all;

    }
    @GetMapping("/beat")
    public Object beat(){
        System.out.println("PersonController.beat---------");
        DataSource bean = applicationContext.getBean(DataSource.class);
        return System.currentTimeMillis();
    }
}
